#ifndef MAIN_PAGE_H
#define MAIN_PAGE_H

#include <Arduino.h>

const char mainPage[] PROGMEM = R"=====(
<!DOCTYPE html>
<html>
<head>
  <title>主页面</title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <style>
    body {
      font-family: Arial, sans-serif;
      background-color: #f5f5f5;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      margin: 0;
    }
    .main-container {
      background: white;
      padding: 2rem;
      border-radius: 8px;
      box-shadow: 0 2px 10px rgba(0,0,0,0.1);
      width: 400px;
      text-align: center;
    }
    h1 {
      color: #333;
      margin-bottom: 1.5rem;
    }
    nav {
      display: flex;
      flex-direction: column;
      gap: 1rem;
    }
    a {
      display: block;
      padding: 0.8rem;
      background-color: #007bff;
      color: white;
      text-decoration: none;
      border-radius: 4px;
      transition: background-color 0.2s;
    }
    a:hover {
      background-color: #0056b3;
    }
    button {
      width: 100%;
      padding: 0.8rem;
      background-color: #dc3545;
      color: white;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      font-size: 1rem;
      transition: background-color 0.2s;
    }
    button:hover {
      background-color: #c82333;
    }
  </style>
</head>
<body>
  <div class="main-container">
    <h1>欢迎</h1>
    <nav>
      <a href="/wifi_config">WiFi配置</a>
      <a href="/change_password">修改密码</a>
      <a href="/wol">网络唤醒</a>
      <button onclick="resetDevice()">重置设备</button>
    </nav>
  </div>
  <script>
    function resetDevice() {
      if (confirm('确定要重置设备吗？这将清除所有配置并重启设备。')) {
        fetch('/reset', {method: 'POST'})
          .then(response => {
            if (response.ok) {
              alert('设备正在重置...');
              setTimeout(() => {
                window.location.href = '/';
              }, 5000);
            }
          });
      }
    }
  </script>
</body>
</html>
)=====";

#endif
